<template>
  <div class="app-container" style="height: 100%">
    <el-row style="display: flex;align-items: center;justify-content: center;height: 100%">
      <el-card style="width: 30%;margin-left: 10px;">
        <div slot="header" class="clearfix" style="text-align: center">
          <span style="color: red;font-size: 14px;">{{ $t('提示:') }}</span>
          <span style="color: red;font-size: 14px;">{{ status === '-1' ? '当前密码为初始密码，请修改密码' : '当前密码' + status + '天内未修改，请修改密码' }}</span>
        </div>
        <resetPwd is-jump-home custom-style="margin-top: 10px" align="center" width="100%" size="medium" :user="user" />
        <div style="text-align: center">
          <span style="color: #409eff;font-size: 14px;cursor: pointer" @click="logOut">退出登录</span>
        </div>
      </el-card>
    </el-row>
  </div>
</template>

<script>
import resetPwd from './resetPwd'
import { getUserProfile } from '@/api/system/user'
export default {
  name: 'Profile',
  // components: { UploadAvatar, userInfo, resetPwd },
  components: { resetPwd },
  data() {
    return {
      user: {},
      roleGroup: {},
      postGroup: {},
      activeTab: 'userinfo',
      status: ''
    }
  },
  created() {
    this.$store.dispatch('getLoginPasswordStatus').then(res => {
      this.status = res.msg
    })
    this.getUser()
  },
  methods: {
    getUser() {
      getUserProfile().then(response => {
        this.user = response.data
        this.roleGroup = response.datas.roleGroup
        this.postGroup = response.datas.postGroup
      })
    },
    logOut() {
      this.$store.dispatch('LogOut').then(() => {
        location.reload()
      })
    }
  }
}
</script>
